package GUI.cmd;

import java.awt.event.ActionEvent;
import java.util.List;

import javax.swing.JFileChooser;

import util.PGNBasicReader;
import GUI.GUI;
import GUI.common.ExceptionI18N;
import GUI.common.cmd.ClientCommand;
import GUI.forms.FAnalyzer;
import board.Game;



public class LoadAnalyzer implements ClientCommand {
	final JFileChooser fc = new JFileChooser();

	public void execute(GUI gui, ActionEvent actionEvent) throws ExceptionI18N {
				
		int returnVal = fc.showOpenDialog(gui);
		List<Game> games=null;
		
		if (returnVal == JFileChooser.APPROVE_OPTION) {            
            
            games = PGNBasicReader.read(fc.getSelectedFile().getAbsolutePath());
            gui.setContentPane(new FAnalyzer(gui, games));
        }
		
		
	}

}
